]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
tray/na-xembed: Use XShape to remove input on socket window
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Wed, 1 May 2024 20:34:58 +0000 (22:34 +0200)
committerSimon McVittie <smcv@debian.org>
Sun, 13 Jul 2025 11:24:58 +0000 (12:24 +0100)
We don't want this window to take any input as, a part from blocking the
events on the shell representation itself, they may potentially make the
plugged window to do anything with the event is processing (such as
showing tooltips). And we don't want this since we only want to send to
those windows only the synthetic events that we explicitly control.

This was already the case before of commit ab60902058 but a similar
approach was not replicated, leading to input events being fully
processed from tray icons plugs.

It requires adding an explicit build dependency on Xext, but this is
something that mutter already depends on so not really a new dependency

Origin: https://gitlab.gnome.org/3v1n0/gnome-shell/-/commits/tray-offscreen-xwindows
Bug: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7613
Bug-Ubuntu: https://bugs.launchpad.net/bugs/2012388

Gbp-Pq: Topic tray-icons
Gbp-Pq: Name tray-na-xembed-Use-XShape-to-remove-input-on-socket-windo.patch

meson.build
src/tray/meson.build
src/tray/na-xembed.c

index e0ac102bbd76665867fcc37c4123a7e0aa8973e7..656414926db92f96624d84f4cc37f3dc4ed94863 100644 (file)
@@ -93,6 +93,7 @@ have_x11 = mutter_dep.get_variable('have_x11') == 'true'
 have_x11_client = mutter_dep.get_variable('have_x11_client') == 'true'
 if have_x11_client or have_x11
   x11_dep = dependency('x11')
+  xext_dep = dependency('xext')
   xfixes_dep = dependency('xfixes')
 endif
 
index 2fc73f3a48af72140f3b7d50f8200af4ae06cab9..c91e94044dd83723e1a248e24b17a4f39f588c48 100644 (file)
@@ -9,6 +9,6 @@ tray_sources = [
 
 libtray = static_library('tray', tray_sources,
   c_args: ['-DG_LOG_DOMAIN="notification_area"'],
-  dependencies: [mutter_dep, mtk_dep, xfixes_dep],
+  dependencies: [mutter_dep, mtk_dep, xfixes_dep, xext_dep],
   include_directories: conf_inc
 )
index 75af21adb21d0d333a126439609ebca7b4f1dd51..1be1e9dd295fc203b13839b19dad2a0e55988351 100644 (file)
@@ -24,6 +24,7 @@
 #include "na-xembed.h"
 
 #include <mtk/mtk-x11.h>
+#include <X11/extensions/shape.h>
 #include <X11/extensions/Xfixes.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
@@ -362,6 +363,7 @@ na_xembed_add_window (NaXembed  *xembed,
     {
       XSetWindowAttributes socket_attrs;
       XWindowAttributes plug_attrs;
+      int shape_major, shape_minor;
       int result;
 
       result = XGetWindowAttributes (xdisplay, priv->plug_window, &plug_attrs);
@@ -407,6 +409,19 @@ na_xembed_add_window (NaXembed  *xembed,
                        priv->plug_window,
                        priv->socket_window,
                        0, 0);
+
+      /* Set an empty input shape on the window so that the socket does not
+       * get any input. Without this we the tray may still get events and for
+       * example show tooltips on hover which we don't want.
+       * This is the quickest way to achieve this, without having to deal these
+       * windows with specific code in mutter.
+       */
+      if (XShapeQueryExtension (xdisplay, &shape_major, &shape_minor))
+        {
+          XShapeSelectInput (xdisplay, priv->socket_window, NoEventMask);
+          XShapeCombineRectangles (xdisplay, priv->socket_window, ShapeInput,
+                                   0, 0, NULL, 0, ShapeSet, 0);
+        }
     }
 
   priv->have_size = FALSE;